package world;

import java.awt.image.BufferedImage;

import utility.Color;
import utility.Point;


public abstract class Piece implements Cloneable{
	/*
	 * canMove method will work like if there is only one piece (pice from) on chessBoard
	 */
	public boolean canMove(Point from, Point to ) {
		
		return true;
	}

	/**
	 * @uml.property  name="color"
	 */
	protected Color color;

	/**
	 * Getter of the property <tt>color</tt>
	 * @return  Returns the color.
	 * @uml.property  name="color"
	 */
	public Color getColor() {
		return color;
	}

	/**
	 * Setter of the property <tt>color</tt>
	 * @param color  The color to set.
	 * @uml.property  name="color"
	 */
	public void setColor(Color color) {
		this.color = color;
	}

	/**
	 * @uml.property  name="position"
	 */
	protected Point position;

	/**
	 * Getter of the property <tt>position</tt>
	 * @return  Returns the position.
	 * @uml.property  name="position"
	 */
	public Point getPosition() {
		return position;
	}

	/**
	 * Setter of the property <tt>position</tt>
	 * @param position  The position to set.
	 * @uml.property  name="position"
	 */
	public void setPosition(Point position) {
		this.position = position;
	}
	public abstract BufferedImage get2dImage();
	
	public abstract String get2DPath();

	
	@Override
	public Object clone() {
		try {
		     Piece p=(Piece) super.clone();
		     p.color=(Color)this.color.clone();
		     if(this.position!=null)
		    	 p.position=(Point) this.position.clone();
		     return p;
		    }
		    catch(CloneNotSupportedException e) {
		    	e.printStackTrace();
		    	return null;
		    }
		
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((color == null) ? 0 : color.hashCode());
		result = prime * result
				+ ((position == null) ? 0 : position.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Piece other = (Piece) obj;
		if (color == null) {
			if (other.color != null)
				return false;
		} else if (!color.equals(other.color))
			return false;
		if (position == null) {
			if (other.position != null)
				return false;
		} else if (!position.equals(other.position))
			return false;
		return true;
	}
	
	
	
}
